using System;
using System.Collections.Generic;
using dbvc.data;
using dbvc.Queries;

namespace dbvc.context.Script
{
    internal static partial class ScriptRole
    {
        public static void Delete(this db_script self)
        {
            GenericQuery<db_script>.Delete(self);
        }
    }

    public class DeleteScript
    {
        private readonly IEnumerable<db_script> items;
        private readonly db_user user;
        private db_activity Activity;

        public DeleteScript(db_user _principal, IEnumerable<db_script> _items)
        {
            user = _principal;
            items = _items;
        }

        public void Execute()
        {
            foreach (db_script Item in items)
            {
                Activity = new db_activity
                               {
                                   action = "delete script",
                                   datestamp = DateTime.Now,
                                   userstamp = user.name
                               };

                Item.Delete();
                Activity.Save();
            }
        }
    }
}